package com.erclab.xpresso.formelements
{
	import mx.controls.TextInput;
	import mx.controls.Label;
	import mx.core.UIComponent;
	import mx.events.DragEvent;
	import mx.events.MoveEvent;
	import mx.events.ItemClickEvent;
	import mx.events.FlexMouseEvent;
	import mx.containers.FormItem;

	public class TextInputFI extends mx.containers.FormItem implements FormElement {
		
		protected var textInput:mx.controls.TextInput;
		protected var destinationColumn:String;
		
		public function TextInputFI():void{
			textInput = new mx.controls.TextInput();
			this.addChild(textInput);
		}		
		
		public function getValue():String {
			return String(this.textInput.text);
		}
		
		public function getName():String
		{
			return String(this.name);
		}
		
		public function createLabel(attachingElement:UIComponent, label:String):void{
			this.label = label;
		}
		
		
		public function setValue(value:String):void {
			this.textInput.text = value;
		}
		
		public function getAttribute(attribute:String):String{
			if (attribute.indexOf("e.") == 0){
				return this.textInput[attribute.substr(2, attribute.length)];
			} else {
				return this[attribute];
			}
		}
		
		public function setAttribute(attribute:String, attributeValue:String):void{
			if (attribute.indexOf("e.") == 0){
				this.textInput[attribute.substr(2, attribute.length)] = attributeValue;
			} else {
				this[attribute] = attributeValue;
			}
		}

		public function prepareForInsert():void{
			this.textInput.text = "";
		}
	}
}